package org.mogu;


import org.mogu.adapter.HeaderGroupAdapter;
import android.widget.GridView;
import android.widget.Spinner;
import android.widget.TextView;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.view.View;

public class HeaderGroup extends Activity  {
	HeaderGroup imageGroup;
	SQLiteDatabase readdb = null;
	Intent intent;
	HeaderGroupAdapter adapter;
	Spinner spin;
	TextView text;
	GridView gridview ;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		imageGroup=this;
		intent=this.getIntent();  
		setContentView(R.layout.headerlist);
		text=(TextView)findViewById(R.id.spinnertext);
		gridview = (GridView) findViewById(R.id.gridview);// 找到main.xml中定义gridview
		adapter=new HeaderGroupAdapter(this);							// 的id
		gridview.setAdapter(adapter);// 调用ImageAdapter.java
		gridview.setOnItemClickListener(new OnItemClickListener() {// 监听事件
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
//				Toast.makeText(imageGroup, "" + position, Toast.LENGTH_SHORT)
//						.show();// 显示信息;
				onBack(String.valueOf(adapter.getCount()-position-1));
			}
		});
	}
	
	public void onBack(String str){
		Bundle bundle = new Bundle();  
        bundle.putString("data",str);  
        
        /*将Bundle对象assign给Intent*/ 
        intent.putExtras(bundle); 
		this.setResult(RESULT_OK, intent); 
		this.finish();
	}
	

//	public void onResume() {
//	    super.onResume();
//	    MobclickAgent.onResume(this);
//	}
//	public void onPause() {
//	    super.onPause();
//	    MobclickAgent.onPause(this);
//	}
}
